package com.dt76.smallloanbackendservice.service.zjs.impl;

import com.dt76.smallloanbackendservice.mapper.zjs.UserMapper;
import com.dt76.smallloanbackendservice.pojo.zjs.User;
import com.dt76.smallloanbackendservice.service.zjs.UserService;
import com.dt76.smallloanbackendservice.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Override
    public List<User> qryAllUser() {
       return userMapper.qryAllUser();
    }

    @Override
    public Page qryPageAllUser(int pageIndex, String queryname, int userId, String queryTime) {
        Page page = new Page();
        page.setPageIndex(pageIndex);//每次更新当前页
        //更新总条数
        page.setTotalCount(userMapper.qryCount(queryname,userId,queryTime));
        List<User> blackUserList =  userMapper.qryPageAllUser(
                (page.getPageIndex()-1)*page.getPageSize(),
                page.getPageSize(),queryname,userId,queryTime);
        page.setRows(blackUserList);
        return page;
    }

    @Override
    public void delUser(int userId) { userMapper.delUser(userId); }
}
